//
//  FlashIndicatorImageView.m
//  iShow
//
//  Created by 杨 敏 on 12-11-28.
//  Copyright (c) 2012年 DreamTeam. All rights reserved.
//

#import "FlashIndicatorImageView.h"
#import "ConstantHeader.h"

@implementation FlashIndicatorImageView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

-(void)dealloc{
    self.indicator=nil;
}
- (void)willMoveToSuperview:(UIView *)newSuperview {
	[super willMoveToSuperview:newSuperview];
	if(!newSuperview) {
        // DLog(@"");
        [self cancelCurrentImageLoad];
	}
}
-(void)startIndicatorAnimating{
    if (!_indicator) {
        self.indicator =[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:_isWhiteIndicator?UIActivityIndicatorViewStyleWhite:UIActivityIndicatorViewStyleGray];
        _indicator.center=CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2);

        
        [self addSubview:_indicator];
        
    }
    [_indicator startAnimating];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    _indicator.center=CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.frame)/2);
}
-(void)endIndicatorAnimating{
    [_indicator stopAnimating];
    [_indicator removeFromSuperview];
    self.indicator=nil;
}

@end
